<fieldset id="sf_fieldset_[?php echo preg_replace('/[^a-z0-9_]/', '_', strtolower($fieldset)) ?]">
  [?php if ('NONE' != $fieldset): ?]
    <h2>[?php echo __($fieldset, array(), '<?php echo $this->getI18nCatalogue() ?>') ?]</h2>
  [?php endif; ?]
  
  <div class="form_tab">
      
  [?php $i = 0 ?]
  [?php $j = 0 ?]

  [?php $form_fields = $configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') ?]
  [?php $last_field = count(array_keys($form_fields[$fieldset])); ?]
      
  [?php foreach ($fields as $name => $field): ?]
    [?php if ((isset($form[$name]) && $form[$name]->isHidden()) || (!isset($form[$name]) && $field->isReal())) continue ?]
    [?php 
      $row_widgets[$j] = array(
        'name'       => $name,
        'attributes' => $field->getConfig('attributes', array()),
        'label'      => $field->getConfig('label'),
        'help'       => $field->getConfig('help'),
        'form'       => $form,
        'field'      => $field,
      );

      $j++;
      $i++;
      
      if ($j == 4) {
        include_partial('<?php echo $this->getModuleName() ?>/form_field', array(
          'row_widgets' => $row_widgets,
          'count' => $i
        ));
         $j = 0;
        $row_widgets = null;
      } elseif ($last_field == $i) {
        include_partial('<?php echo $this->getModuleName() ?>/form_field', array(
        'row_widgets' => $row_widgets,
        'count' => $i
        ));
      }
    ?]
  [?php endforeach; ?]
  
  
  </div>
</fieldset>
